package com.ocom.company.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ocom.common.entity.company.EntityRecentAdminAccount;
import com.ocom.common.vo.company.GetLoginCompanyListVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IDaoRecentAdminAccount extends BaseMapper<EntityRecentAdminAccount> {

    @Select("select" +
            " C.com_id as companyId , C.com_name as companyName , M.id as userId , M.user_name as accountName ,M.role , R.role_name as roleName , M.dept_id as deptId , M.region_id as regionId , M.bns_id as merchId ,M.phone,R.parent_role as parentRole " +
            " from recent_admin_account as A ,company_list as C, mng_user_info as M  left join company_role as R on R.role_id = M.role ${ew.customSqlSegment}")
    List<GetLoginCompanyListVo> selectAdminLoginList(@Param(Constants.WRAPPER) Wrapper wrapper);

    @Select("select " +
            " C.com_id as companyId , C.com_name as companyName , M.id as userId , M.user_name as accountName ,M.role , R.role_name as roleName , M.dept_id as deptId , M.region_id as regionId , M.bns_id as merchId ,M.phone,R.parent_role as parentRole " +
            " from  company_list as C left join mng_user_info as M  on C.com_id = M.com_id left join company_role as R on R.role_id = M.role ${ew.customSqlSegment}")
    List<GetLoginCompanyListVo> selectUserLoginList(@Param(Constants.WRAPPER) Wrapper wrapper);
}
